package com.javase;

public class Method01 {
    public static void main(String[] args) {
        Person person = new Person();
        person.speak();
        person.cal01();
        person.cal02(10000);
        int res = person.getSum(50,50);
        System.out.println("返回的值是"+res);
    }
}
class Person{
    String name;
    int age;
    public void speak(){
        System.out.println("我是一个好人");
    }
    public void cal01(){
        int sum = 0;
        for (int i = 1;i<=1000;i++){
            sum += i;
        }
        System.out.println("从1加到1000等于"+sum);
    }
    public void cal02(int n){
        int sum = 0;
        for (int i = 1;i<=n;i++){
            sum += i;
        }
        System.out.println("从1加到"+n+"等于"+sum);
    }
    //public:公开的类  int 返回一个int类型的值
    public int getSum(int num1, int num2){
        int sum = num1 + num2;
        return sum;
    }
}
